<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<c-rt:set var="imgDomain"><%=ServerValue.getImgDomain()%></c-rt:set>
<c-rt:set var="frontContextPath"><%=ServerValue.getFrontContextPath()%></c-rt:set>
<c-rt:set var="ss" value='<%=System.currentTimeMillis()%>'/>
<script type="text/javascript" src="/js/pageable.js"></script>
<script type="text/javascript" src="/js/jquery.autocomplete.min.js"></script>
<script type="text/javascript" src="/js/jquery.qtip-1.0.0-rc3.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<script language="javascript">
	var haveInventory=false;
	var content;
	var specs=new Array();
	var maxPOQ=new Array();
	var minPOQ=new Array();
	var inventory=new Array();
	var specNames=new Array();
	<%--售价(可有小数点)--%>
	jQuery.fn.ydPrice = function() {
	    return this.each(function() {
	    	$(this).keyup(function(){
				$(this).val($(this).val().replace(/[^\d\.}]/g,''));
			});
	    });
	};
	<%--只能输入正整数或0--%>
	jQuery.fn.onlyInteger = function() {
	    return this.each(function() {
	    	$(this).keyup(function(){
				$(this).val($(this).val().replace(/[^0-9]/g,''));
			});
	    });
	};	

	$().ready(function(){
		$("body").addClass("payment");
		$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
		$("#chang_image").click(function(){
			$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
		});
		$("#contactName").alpha();		
		$("#zipCode").onlyInteger();
		$("#mobile").onlyInteger();
		$("#areaCode").onlyInteger();
		$("#phone").onlyInteger();
		$("#extension").onlyInteger();
		$("#subVrtlBlnc").ydPrice();	
		
		$("#loadingData").dialog({
			  title: '资料处理中,请稍候...',
				bgiframe: true,
				autoOpen: false,
				height: 150,
				width:280,
				modal: true
			});			
		//从收货地址簿选取
		$("#myAddBook").click(function(){
			$.ajax({
				beforeSend: function(){
					$("#loadingData").dialog("open");
					openDialog("从收货地址簿选取",$("#myAddBookDialog").load("${frontContextPath}/shopping/tuangou/loadMyAddBook.do?ss=${ss}&id=${st.productId}"),700,'auto');
				},	
				cache: false,
				success:　function(){
					$("#loadingData").dialog("close");
				}
			}); 
		});		
		<%--default hide message --%>
		$("#mainCodeLabel").hide();
		$("#secondCodeLabel").hide();
		$("#codeTip").hide();

		$("#contactNameTip").hide();
		$("#provinceTip").hide();
		$("#addrTip").hide();
		$("#telTip").hide();
		$("#mailTip").hide();	
		
		$("#storeAreaTip").hide();
		$("#storeImageTip").hide();
		$("#dpn_contactNameTip").hide();
		$("#dpn_telTip").hide();
		$("#dpn_mobileTip").hide();
		$("#dpn_mailTip").hide();	
		

		<c-rt:set var="haveInventory" value="false"/>
		var specIndex=0;
		<c-rt:forEach items="${product.specifications}" var="spec" varStatus="status">
			<c-rt:if test="${spec.isDelete eq 'N'}">
				<c-rt:if test="${product.productType ne 6}">
					$(document.body).data("${spec.specificationId}",specIndex);
					specs[specIndex]="${spec.specificationId}";
					specNames[specIndex]="${spec.specificationName}";
					maxPOQ[specIndex]="${spec.maxCountPerOrder}";
					minPOQ[specIndex]="${spec.minCountPerOrder}";
					inventory[specIndex]="${prodInvMap[spec.specId].inventory}";
					specIndex++;
					<c-rt:if test="${prodInvMap[spec.specId].inventory > 0 && prodInvMap[spec.specId].inventory ge spec.minCountPerOrder && product.productType ne '6'}">
							haveInventory=true;
							<c-rt:set var="haveInventory" value="true"/>
					</c-rt:if>
				</c-rt:if>
				<c-rt:if test="${product.productType eq 6}">
					specs[specIndex]="${spec.specificationId}";
				</c-rt:if>
			</c-rt:if>
		</c-rt:forEach>
		initSpec();

		<c-rt:forEach items="${product.specMajors}" var="specMajor" varStatus="status">
			$(document.body).data('${specMajor.mainSpecId}',${specMajor.jsonDetail});
    </c-rt:forEach>
		
		<c-rt:if test="${product.productType ne '6'}">
		$(":a[id*=ms_]").each(function(){
			var msId = $(this).attr('id').split('_')[1];
			var secSpec = $(document.body).data(msId);
			var haseQty = false;
			$(secSpec).each(function(index, temp) {
				if(inventory[$(document.body).data(temp.specId)]>0){
					haseQty = true;
				}
			});
			if(!haseQty){
				$('<span class="pd-type-none" title="'+$(this).text()+'-售完">'+$(this).html()+'</span>').insertAfter($(this));
				$(this).remove();
			}
		});
		<%--default select--%>
		if($(":a[onclick*=selectProdMainSpec]").length>0){
			$(":a[onclick*=selectProdMainSpec]").eq(0).click();
		}
		</c-rt:if>

		<%--當客人無帳戶餘額,不可以勾選用我的帳戶餘額--%>
		if(parseFloat($("#myVirtualBalance").text())==0){
			$("#subVrtlBlnc").attr("disabled",true); 
			$("#chkVrtBlnc").attr('disabled',true); 
			$("#paytype40").attr("disabled",true); 
		}

		<%--當客人無礼品卡,不可以勾選用我的礼品卡--%>
		if(parseFloat($("#myGiftCardBalance").text())==0){
			$("#subGiftCard").attr("disabled",true); 
			$("#chkGiftCard").attr('disabled',true); 
			$("#paytype40").attr("disabled",true); 
		}				

		<%--處理帳戶餘額chkVrtBlnc--%>	
		$('#chkVrtBlnc').click(function(){
			$("#subVrtlBlnc").css("background-color","white");	  
      if (this.checked){
	     	$("#useWallet").show();
	     	$("#subVrtlBlnc").attr("readOnly", false); 
	     	if($("#subVrtlBlnc").val()==""){
       		$("#chkVrtBlnc").val(parseFloat(0).toFixed(1));
       		$("#subVrtlBlnc2").val(parseFloat(0).toFixed(1));
  			}else{
   				$("#chkVrtBlnc").val($("#subVrtlBlnc").val());
   				$("#subVrtlBlnc2").val($("#subVrtlBlnc").val());
   			}
      }else {
		  	initWallet();
      }
      ProcessCalcuTotal();
    });

		<%--處理禮品卡chkGiftCard--%>	
		$('#chkGiftCard').click(function(){
			$("#subGiftCard").css("background-color","white");	  
      if (this.checked){
	     	$("#useGiftCard").show();
	     	$("#subGiftCard").attr("readOnly", false); 
	     	if($("#subGiftCard").val()==""){
       		$("#chkGiftCard").val(parseFloat(0).toFixed(1));
       		$("#subGiftCard2").val(parseFloat(0).toFixed(1));
  			}else{
   				$("#chkGiftCard").val($("#subGiftCard").val());
   				$("#subGiftCard2").val($("#subGiftCard").val());
   			}
      }else {
    	  initGiftCard();
      }
      ProcessCalcuTotal();
    });	    

	 	$("#confirmGiftCard").click(function(){	 
		 	if($("#subGiftCard").val()==""){
  			$("#chkGiftCard").val(0.0);
  			$("#subGiftCard2").val(0.0);
			}else{
				 $("#chkGiftCard").val(parseFloat($("#subGiftCard").val()).toFixed(1));
	       $("#subGiftCard2").val(parseFloat($("#subGiftCard").val()).toFixed(1)); 
			}        
		 	ProcessCalcuTotal();     
     	var tmpSVB=0.0;
     	if($("#subGiftCard").val()==""){
    		tmpSVB=0.0;
			}else{
				tmpSVB=$("#subGiftCard").val();
			}
	    if(parseFloat($("#tempTotalAmount").val())<0){
	       alert("您输入的支付金额超过了订单金额，请重新输入欲支付金额。");
	       $("#subGiftCard").focus();
	    }else if(parseFloat(tmpSVB)>parseFloat($("#myGiftCardBalance").text())){
					alert('您输入的金额大于礼品卡余额，请重新输入抵用金额。');
					$("#subGiftCard").focus();
			}else if(parseFloat($("#finalTotalAmount").val())==0){
				$("#allpaymsg").show(); 
	     		$("input[id^='paytype']").each(function(i){
						if(this.id=='paytype40'){
							$(this).attr("disabled", false);
							$(this).attr("checked", true);
						}else{
							$(this).attr("disabled", true);
							$(this).attr("checked", false);
						}
					});
	     		$('input[name=bankCode]').attr("checked",false);
					$('input[name=bankCode]').attr("disabled",true);
					$('input[name=paytype][value=70]').attr("checked",false);
					$('input[name=paytype][value=70]').attr("disabled",true);
		      $("#useGiftCard").hide();
		      $("#subGiftCard").attr("readOnly", true);
		      $("#subGiftCard").css("background-color","silver");
	    }else{  
				$("#useGiftCard").hide();
	   		$("#subGiftCard").attr("readOnly", true);
	   		$("#subGiftCard").css("background-color","silver");
	    }
	    ProcessCalcuTotal();
  	});		
	    
	 	$("#confirmWallet").click(function(){	 
		 	if($("#subVrtlBlnc").val()==""){
	 			$("#chkVrtBlnc").val(0.0);
	 			$("#subVrtlBlnc2").val(0.0);
			}else{
				$("#chkVrtBlnc").val(parseFloat($("#subVrtlBlnc").val()).toFixed(1));
				$("#subVrtlBlnc2").val(parseFloat($("#subVrtlBlnc").val()).toFixed(1)); 
			}             
	    ProcessCalcuTotal();
	    var tmpSVB=0.0;
	    if($("#subVrtlBlnc").val()==""){
	    	tmpSVB=0.0;
			}else{
				tmpSVB=$("#subVrtlBlnc").val();
			}
	    if(parseFloat($("#tempTotalAmount").val())<0){
	      alert("您输入的支付金额超过了订单金额，请重新输入欲支付金额。");
	      $("#subVrtlBlnc").focus();
	    }else if(parseFloat(tmpSVB)>parseFloat($("#myVirtualBalance").text())){
				alert('您输入的金额大于账户余额，请重新输入抵用金额。');
				$("#subVrtlBlnc").focus();
			}else if(parseFloat($("#finalTotalAmount").val())==0){
				$("#allpaymsg").show(); 
     		$("input[id^='paytype']").each(function(i){
					if(this.id=='paytype40'){
						$(this).attr("disabled", false);
						$(this).attr("checked", true);
					}else{
						$(this).attr("disabled", true);
						$(this).attr("checked", false);
					}
				});
     		$('input[name=bankCode]').attr("checked",false);
				$('input[name=bankCode]').attr("disabled",true);
				$('input[name=paytype][value=70]').attr("checked",false);
				$('input[name=paytype][value=70]').attr("disabled",true);
	      $("#useWallet").hide();
	      $("#subVrtlBlnc").attr("readOnly", true);
	      $("#subVrtlBlnc").css("background-color","silver");
	    }else{  
				$("#useWallet").hide();
	   		$("#subVrtlBlnc").attr("readOnly", true);
	   		$("#subVrtlBlnc").css("background-color","silver");
	    }
	    ProcessCalcuTotal();
  	});		
	 	  				
		<%--选择网上银行支付--%>
		$("input[name=bankCode]").click(function(){
			$('input[name=paytype]').attr("checked",false);
		});
		<%--选择信用卡单期支付--%>
		$("input[name=paytype]").click(function(){
			$('input[name=bankCode]').attr("checked",false);
		});
		
		<%--新增至购物车--%>
		$("#saveToCart").click(function(){
			if ( "" == $("#msem1").html() ){
				$("#mainCodeLabel").show();
			}
			if ( "" == $("#msem1").html() ){
				$("#secondCodeLabel").show();
			}			
			if (typeof($("#qty").val()) == "undefined"){
				alert("请选择数量");
			}else{
				addToProductList($("#major"),$("#spec"),$("#qty"));
				$("#div_plist").show();
			}
		});

		$("#submitTuangou").click(function(){
			if ( $("#prodList tr").length == 0 ){
			   alert("团购商品至少需一件，请重新选择商品");
			   return false;
			}
			if (!$('input[name=delivery]').is(":checked")){
				alert("请选择配送方式");
				return false;
			}
			$("#show_receiver_addr").parent().parent().hide();
			$("#edit_receiver_addr").show();
			chkReceiverData($('input[name="delivery"]:checked').val());
			if ($("#invotype02").is(":checked")){
				if($("#invoTitle").val()==""){
	       	alert('请输入单位');
	       	return false;
				}
       	if($("#invoTitle").val().length+chineseCount($("#invoTitle").val())>40){
    	  	alert("请使用 中文20个字以内 或 英文40个字以内");
         	return false;
 		    }
			}	
			<%--儲存收件人(检查载入的收货人地址簿资料是否正确)--%>
			var inputResult = null;
			if ($('input[name=delivery]').val() == "nml"){
				var inputResult = saveInput("", -1, $("#contactName").val(),$("#province").val(),$("#city").val(),$("#district").val(),$("#addr").val(),$("#zipCode").val(),$("#mobile").val(),$("#areaCode").val(),$("#phone").val(),$("#extension").val(),$("#mail").val(),"nml");
				if ( null != inputResult){
					return false;
				}
			}
		  $.post("${frontContextPath}/member/saveAddressBook.do?ss=${ss}",{abId:-1,contactName:$('#editcontactName').val(),province:$('#editprovince').val(),city:$('#editcity').val(),district:$("#editdistrict").val(),zipCode:$('#editzipCode').val(),addr:$('#editaddr').val(),mobile:$('#editmobile').val(),areaCode:$("#editareaCode").val(),phone:$('#editphone').val(),extension:$('#editextension').val()},
					function callback(result){
						//alert("saveAddressBook_result:"+result);
						},
					"json");
			<%--支付金额检核--%>
			if($("#useWallet").css("display") != "none"){
				alert("若要使用账户余额，请按「确认使用」按钮，否则请反勾选。");
				$("#chkVrtBlnc").focus();
				return false;
			}						
			if ($("#chkVrtBlnc").attr('checked')){
				var tmpSubVB=0.0;
				if($("#subVrtlBlnc").val()==""){
          tmpSubVB=$("#subVrtlBlnc").val(0.0);
	    	}else{
	    		tmpSubVB=parseFloat($("#subVrtlBlnc").val()).toFixed(1);
	    	}							
	      $("#chkVrtBlnc").val(tmpSubVB);
	      if(parseFloat(tmpSubVB)>parseFloat($("#myVirtualBalance").text())){
					alert('您输入的金额大于账户余额，请重新输入抵用金额。');
					$("#subVrtlBlnc").focus();
					return false;
				}
      } else {
       	$("#chkVrtBlnc").val(0.0);    
      }	 
	    if(parseFloat($("#chkVrtBlnc").val())>parseFloat($("#editTotalAmount").val())){
				alert('账户余额不可大於实际应缴总金额');
				$("#subVrtlBlnc").focus();
				return false;
			} 		
	    if($("#useGiftCard").css("display") != "none"){
				alert("若要使用礼品卡，请按「确认使用」按钮，否则请反勾选。");
				$("#chkVrtBlnc").focus();
				return false;
			}						
			if ($("#chkGiftCard").attr('checked')){
				var tmpSubVB=0.0;
				if($("#subGiftCard").val()==""){
	      tmpSubVB=$("#subGiftCard").val(0.0);
	    	}else{
	    		tmpSubVB=parseFloat($("#subGiftCard").val()).toFixed(1);
	    	}							
	      $("#chkGiftCard").val(tmpSubVB);
	      if(parseFloat(tmpSubVB)>parseFloat($("#myGiftCardBalance").text())){
					alert('您输入的金额大于礼品卡余额，请重新输入抵用金额。');
					$("#subGiftCard").focus();
					return false;
				}
		  } else {
		   	$("#chkGiftCard").val(0.0);    
		  }	 
	    if(parseFloat($("#chkGiftCard").val())>parseFloat($("#editTotalAmount").val())){
				alert('礼品卡不可大於实际应缴总金额');
				$("#chkGiftCard").focus();
				return false;
			} 					
			<%--支付方式检核--%>
			<%--未选用任何支付方式--%>
			if ( $('input[name=paytype]').is(":checked") == false && $('input[name=bankCode]').is(":checked") == false){
				$("#chkPayTypeTip").show();
				return false;
			}else{
				<%--账户余额付清--%>
				if ( $("#paytype40").is(":checked") ){
					$("#chkPayTypeTip").hide();
				}else{
					if (!$('input[name=bankCode]').is(":checked") && !$('input[name=paytype][value=70]').is(":checked")){
						$("#chkPayTypeTip").show();
						return false;
					}else{
						$("#chkPayTypeTip").hide();
					}
				}				
			}
			<%--验证码检核--%>
      if(($("#ccode").attr('value') == "")){
    	  	$("#ccode").focus();	
       		$("#codeTip").html('请填验证码');
       		$("#codeTip").show();
					return false;
      }else{
    	  if("on"=="<%=ServerValue.getBlockOrderPaymentType()%>"){
    		  if($("#ismobileVaild").val()=="false"){
       	  	openDialog("手机验证",$("#mobileVaildDialog").load("${frontContextPath}/shopping/orderInfo/loadMobilVaild.do?ss=${ss}"),500,'auto');
    		  }
				}
    	  if($("#ismobileVaild").val()=="true"){
    	  	$.post("${frontContextPath}/shopping/tuangou/jsonChkValidateNum.do?ss=${ss}",{ccode:$("#ccode").val()},
	   				ccodeCallback,"json");
    	  }
      }
		});

		$("#province").change(function() {
			var optionsCity = '<option value="">== 选择城市 ==</option>';
			$("#city").html(optionsCity);
			var options = '<option value="">== 选择地区 ==</option>';
			$("#district").html(options);
			queryProvince2('','');
			<%--计算运费(团购商品目前都免运)--%>
			//var tmpProvince=$("#province").find('option:selected').val();
	   });	

		$("#city").change(function() {
			queryCity2('');
	  });	

		$("#district").change(function() {
			queryDistinct();
		});   

		
		<%--发票信息--%>
		$("#invotype01").attr("checked",true); 
		$("#invoTitle").hide();
		$('#invotype01').click(function(){
			$("#invoTitle").val("");
			$("#invoTitle").hide();
		});
		$('#invotype02').click(function(){
			$("#invoTitle").show();
		});

		<c-rt:if test="${resultDaphne}">
		<%--达芙妮daphne start--%>
		$("#storeArea").children().each(function(){
			var storeAreaInit=$("#storeAreaInit").val();
		  if ($(this).text()==storeAreaInit){
		  	$(this).attr("selected","true"); <%--或是給selected也可--%>
		    storeAreaSelected(storeAreaInit);
		  }
		});
		
		<%--達芙妮門店區域選擇--%>	
		$("#storeArea").change(function() {
		  $("#imagePreview").html("<img src='/images/daphne/000.gif'>");
			$("#pickStore").html("");
	    var storeArea = $("option:selected", this).val();
			$.post("${frontContextPath}/shopping/orderInfo/findDaphnes.do?ss=${ss}",{storeArea:storeArea},callback,"json");
			function callback(actionResult){
				if(actionResult!=null){
			  	var arr_text = actionResult.split("$");										
					var options = '<option value="">请选择</option>';
					for(i=0;i<arr_text.length;i++){
						v=arr_text[i].split(",");
						options += '<option value="' + v[0] + '">' + v[1] + '</option>';
					}
					$("#storeImage").html(options);
					$('#storeImage option:first').attr('selected', 'selected');
				}	
			}
			if($("#storeArea").find('option:selected').text()=="请选择"){
				var options = '<option value="">请选择</option>';
				$("#storeImage").html(options);
			}
	   });	
		
		<%--達芙妮門店地址選擇--%>	
		$("#storeImage").change(function() {
			var tmpstoreArea=$("#storeArea").find('option:selected').text();
			var storeId = $("option:selected", this).val();
			$("#imagePreview").html(storeId ? "<img src='/images/daphne/" + storeId + ".jpg'>" : "<img src='/images/daphne/000.gif'>");
			if($("option:selected", this).text()=="请选择"){
				$("#pickStore").html("未选取");
				$("#dpn_addr").val("");
			}else{
				$("#pickStore").html("上海市，"+tmpstoreArea+"，"+$("option:selected", this).text());
				$("#dpn_addr").val($("option:selected", this).text());
			}
			$("#dpn_district").val(tmpstoreArea);
			$("#storeId").val(storeId);
		 });
		</c-rt:if>
		
		<%--选择门市取货或快递--%>
		$(":input[name=delivery][type=radio]").click(function(){
			if ( $(this).val() == "nml" ){
				loadNmlData();
				$("#div_nml").show();
				$("#div_dpn").hide();
			}
			if ( $(this).val() == "dpn" ){
				loadDpnData();
				$("#div_nml").hide();
				$("#div_dpn").show();
			}
		});
	});
		
	<%--修改收貨人資料--%>
	function editReceiverAddr(objBtn){
		var thisVal = "";
		if ( objBtn == "dpn" ){
			thisVal = objBtn + "_";
		}
		$("#" + thisVal + "show_receiver_addr").parent().parent().hide();
		$("#" + thisVal + "edit_receiver_addr").show();
	}
	
	<c-rt:if test="${product.productType ne '6'}">
	function selectProdMainSpec(msId){
		if($("#ms_"+msId).attr('class')!='pd-type-fo'){
			changeInventory('');
			var secSpec = $(document.body).data(msId);
			var secSpecHtml = '';
			$(secSpec).each(function(index, temp) {
				if(inventory[$(document.body).data(temp.specId)]>0){
					secSpecHtml += '<a class="pd-type" href="javascript:;" id="ss_'+ temp.specId +'" onclick="selectProdSecondSpec(' + temp.specId + ');" title="'+temp.specName+'">'+temp.specName+'</a>';
				}else{
					secSpecHtml += '<span class="pd-type-none" title="'+temp.specName+'-售完">'+temp.specName+'-售完</span>';
				}
			});
			$("#secSpecArea").html(secSpecHtml);
			$(":a[id*=ms_].pd-type-fo").attr('class','pd-type');
			$("#ms_"+msId).attr('class','pd-type-fo');
			$("#msem1").html($("#ms_"+msId).attr('title'));
			$("#ssem1").html('');
			$('#major').val(msId);
			if($(":a[id*=ss_]").length>0){
				$(":a[id*=ss_]").eq(0).click();
			}
		}
	}
	
	function selectProdSecondSpec(ssId){
		if($("#ss_"+ssId).attr('class')!='pd-type-fo'){
			$(":a[id*=ss_]").attr('class','pd-type');
			$("#ss_"+ssId).attr('class','pd-type-fo');
			$(":em[id*=ssem]").html();
			$("#ssem1").html($("#ss_"+ssId).attr('title'));
			$('#spec').val(ssId);
			changeInventory(ssId);
		}
	}
	function changeInventory(specId){
		ie7Disabled();
		var rowAt;
		for(i=0;i<specs.length;i++){
			if(specId==specs[i]){
				rowAt=i;
				break;
			}
		}
		
		var min=minPOQ[rowAt];
		var max=parseInt(maxPOQ[rowAt],10);
		if(parseInt(maxPOQ[rowAt],10) > parseInt(inventory[rowAt],10)){
			max=inventory[rowAt];
		}
		if(haveInventory){
			$('#qty').children().each(function(){
				$(this).remove();
			});
			for(i=min;i<=max;i++){
				if(inventory[rowAt]==0 || max<min){
					$('#qty').append("<option disabled=\"disabled\" value=\""+i+"\">"+i+"</option>");
				}else{
					$('#qty').append("<option value=\""+i+"\">"+i+"</option>");
				}
			}
		}
	}	
	</c-rt:if>

	function initSpec(){
		<c-rt:if test="${product.productType ne '6'}">
			initSpecDefaultQty();
		</c-rt:if>
		<c-rt:if test="${product.productType eq '6'}">
			$('#spec').attr('value', specs[0]);
		</c-rt:if>
	}	
	function initSpecDefaultQty(){
		$('#qty').children().each(function(){
			$(this).remove();
		});
		if(haveInventory){
			$('#qty').append("<option value=\"\">1</option>");
		}else{
			$('#qty').append("<option value=\"\">0</option>");
		}
	}	

	function checkInventory(specId,selQty){
		var rowAt;
		for(i=0;i<specs.length;i++){
			if(specId==specs[i]){
				rowAt=i;
				break;
			}
		}
		var min=minPOQ[rowAt];
		var max=parseInt(maxPOQ[rowAt],10);
		if(parseInt(maxPOQ[rowAt],10) > parseInt(inventory[rowAt],10)){
			max=inventory[rowAt];
		}
		if(haveInventory){
			if ( parseInt(selQty,10) > parseInt(max,10) ){//购买数大于最大可购买数
				return false;
			}
			if ( parseInt(selQty,10) < parseInt(min,10) ){//购买数小于最小可购买数
				return false;
			}
			return true;
		}
		return false;
	}
		
	function ie7Disabled(){
		if ($.browser.msie && parseFloat($.browser.version) == 7) {
			$("option:disabled").css('color', 'graytext');
		  $("select").find("[disabled]").addClass("disabled").removeAttr("disabled");
		  $("select").change(function(){
				var selected = $(this).val();
 				var disabled = $(this).find("[value="+selected+"]").hasClass("disabled");
 				if (disabled) {
 					alertDialog("","此属性已售完,无法选择");
  				$(this).find("option:first").attr("selected","selected");
 				}
      });
		}
	}	
	<%--删除tr--%>
	function deleteRow(elem) {
	  <%--先抓到是哪一個 tr--%>
	  var row = $(elem).parent().parent();
	  <%-- 移除它--%>
	  row.fadeOut('normal', function() {
	    row.remove();
	  });
	}
	<%--删除规格--%>
	function delRow(objId){
		$("#" + objId).remove();
		calculatorTotalAmount();
	}
	<%--点击确定后添加到商品列表--%>
	function addToProductList(majorObj,specObj, qtyObj) {
		var majorVal = majorObj.val();
    var specVal = specObj.val();
    var qtyVal = qtyObj.val();
    if (specVal == null || qtyVal == null) {
        return;
    }
    var mainSpecName = $("#msem1").text();
    var secondSpecName = $("#ssem1").text();
    var shelfPrice = "${st.price}";
    if ($("#tId_" + specVal).length > 0) {
    	<%--购物车已经存在这个商品,获得原有的商品数量,并且加上现在的购买数量.同时,价格也随之变化--%>
    	addSpecQtyByMajor($("#pQty_" + specVal),specVal,qtyVal);
    } else {
        try {
        	$("#prodList").append("<tr id='tId_" + specVal + "'>" +
    				"<td class=\"pdtype-main\"><input type=\"hidden\" name=\"tuangouSpecId\" value=\"" + specVal + "\"/><a class=\"pd-type\" href=\"javascript:;\" title=\"" + mainSpecName + "\">" + $("#ms_" + majorVal).html() + "</a></td>" +
    				"<td>" + secondSpecName + "</td>" +
    				"<td>￥<span id=\"singlePrice_"  + specVal + "\">" + shelfPrice + "</span></td>" +
    				"<td><span onclick=\"minusSpecQty(this,'" + specVal + "');\" class=\"qty-minus\"></span><input type=\"text\" class=\"qty-input\" name=\"tuangouQty\" value=\"" + qtyVal + "\" id=\"pQty_" + specVal + "\"/><span onclick=\"addSpecQty(this,'" + specVal + "');\" class=\"qty-add\" readonly=\"readonly\"></span></td>" +
    				"<td>￥<span id=\"pPrice_" + specVal + "\">" + parseFloat(shelfPrice) * parseInt(qtyVal,10) + "</span></td>" +
    				"<td><a href=\"javascript:void(0);\" class=\"qty-del\" onclick=\"delRow('tId_" + specVal + "');\">删除</a></td>" +
    				"</tr>");
						<%--不允許輸入--%>
    				$(":input[id*='pQty_']").each(function(){
    					$(this).keypress(function(event) {event.preventDefault();}); 
    				});
        } catch (e) {
            alert(e);
        }
    }
    calculatorTotalAmount();
	}

	function popUpQtip(obj,msg){
		$(obj).qtip({
			content: msg,
			style: {
	      width: 200,
	      padding: 5,
	      background: '#fff3f2',
	      color: '#a10000',
	      textAlign: 'center',
      	border: {
          width: 1,
          radius: 5,
          color: '#ffd3cd'
      	},
      	tip: 'topLeft',
      	name: 'red'
	    },
    	show: 'focus',
    	hide: 'blur'
		});
		$(obj).focus();
  	<%--3s后自动消失,并且阻止绑定的事件--%>
    setTimeout(function () {
    	$(obj).blur();
      $(obj).unbind("focus");
    }, 3000);
	}
	<%--增加商品数量--%>
	function addSpecQty(obj,addSpecId) {
		addSpecQtyByMajor(obj,addSpecId,1);
	}
	<%--增加商品数量--%>
	function addSpecQtyByMajor(obj,addSpecId,addSpecQty) {
		<%--原有商品数量--%>
	   var originalNum = $("#pQty_" + addSpecId).val();
	   <%--单价--%>
	    var singlePrice = $("#singlePrice_" + addSpecId).text();
	    var currentNum = parseInt(originalNum) + parseInt(addSpecQty);
	    if ( checkInventory(addSpecId,currentNum) ){
		    $("#pQty_" + addSpecId).val(currentNum);
		    calculatorSubTotal(addSpecId);
		    calculatorTotalAmount();
		    popUpQtip($(obj),"商品数量增加了");
			}else{
				popUpQtip($(obj),"无法再增加了，商品有最大购买量限制");
			}
	}

	<%--减少商品数量--%>
	function minusSpecQty(obj,minusSpecId) {
		<%--原有商品数量--%>
	  var originalNum = $("#pQty_" + minusSpecId).val();
    var currentNum = originalNum - 1;
    if ( checkInventory(minusSpecId,currentNum) ){
	    $("#pQty_" + minusSpecId).val(currentNum);
	    <%--单价--%>
		  calculatorSubTotal(minusSpecId);
		  calculatorTotalAmount();
		  popUpQtip($(obj),"商品数量减少了");
    }else{
    	popUpQtip($(obj),"无法再减少了，商品有最小购买量限制");
    }
	}
	
	<%--变换单条的价格--%>
	function calculatorSubTotal(specId) {
	    var singlePrice = $("#singlePrice_" + specId).text();
	    var currentNum = $("#pQty_" + specId).val();
	    var currentPrice = (parseInt(currentNum) * parseFloat(singlePrice) * 100) / 100;
	    $("#pPrice_" + specId).text(currentPrice);
	}
	
	<%--计算总价--%>
	function calculatorTotalAmount() {
			<%--首先获得当前的总数和总金额--%>
	    var currentCount = 0;
	    var currentTotalPrice = 0;
	    $("#prodList tr").each(function () {
        try {
            var id = $(this).attr("id");
            if (id == null) {
                return;
            }
            id = id.split("_")[1];
            var count = $("#pQty_" + id).val();
            var price = $("#singlePrice_" + id).text();
            currentCount += parseInt(count);
            if (price != null || price != "") {
                currentTotalPrice = (currentTotalPrice * 100 + parseFloat(price) * parseInt(count) * 100) / 100;
            }
        } catch (e) {
        }
	    });
	    <%--计算加入新购买的商品所得到的总数和总金额--%>
	    $("#spTotalCount").html(currentCount);
	    $("#spTotalAmount").html(currentTotalPrice);
	    $("#editTotalAmount").val(currentTotalPrice);
	    if ( $("#prodList tr").length == 0 ){
		    alert("团购商品至少需一件，请重新选择商品");
		    $("#select_prod").show();
		    $("#shoppingCatTb1").show();
		    $("#shoppingCatTb2").hide();
		    $("#changeSelected").hide();
		    $("#selectedDone").show();
	    }
	}

	<%--点击选好了--%>
	function selectedDone() {
	    var ret = loadAllProductSpecs();
	    if (!fireAlarm(ret)) {
	        return;
	    }
	    $('#select_prod').hide();
	    <%--将购买的商品连接成字符串,放置到隐藏字段中--%>
	    $("#productsArray").val(ret.join("|"));
	    if ($("#prodList td").length <= 1) {
	        alert('请选择商品');
	        return;
	    }
	    <%--初始化账户余额--%>
			initWallet();
	    changeTb("hide");
	}
	
	<%--改一改--%>
	function changeSelected() {
    changeTb("show");
	}

	function changeTb(displayObj){
		if ( "hide" == displayObj ){
			$("#prodList2").html("");
			$("#prodList tr").each(function(){
				try {
		      var id = $(this).attr("id");
		      id = id.split("_")[1];
		      var tmp = "";
		      if (id) {
			      tmp = "<tr>";
			      $(this).children("td").each(function(index,item){
				      if ( index == 0 ){
				    	  tmp = tmp + "<td class='pdtype-main'>" + $(item).children("a").html() + "</td>";
				      }else if ( index == 1 ){
				    	  tmp = tmp + "<td>" + $(item).html() + "</td>";
				      }else if ( index == 2 ){
				    	  tmp = tmp + "<td>￥" + $("#singlePrice_" + id).text() + "</td>";
				      }else if ( index ==3 ){
				    	  tmp = tmp + "<td>" + $("#pQty_" + id).val() + "</td>";
				      }else if ( index == 4 ){
				    	  tmp = tmp + "<td>￥" + $("#pPrice_" + id).text() + "</td>";
			    	  }else if ( index== 5){
			    		  tmp = tmp + "<td>-</td>";
			    	  }else if ( index <= 1){
				    	  tmp = tmp + "<td>" + $(item).html() + "</td>";
			    	  }  
			      });
			      tmp = tmp + "</tr>";
					  $("#prodList2").append(tmp); 
		      }
				} catch (e) {
	        alert(e);
	      }
			});
			$("#shoppingCatTb2 > tfoot > tr > td > span > em").eq(0).html($("#spTotalCount").text());
			$("#shoppingCatTb2 > tfoot > tr > td > span > em").eq(1).html($("#spTotalAmount").text());
		  $("#shoppingCatTb1").hide();
		  $("#shoppingCatTb2").show();
		  showDiv();
		  $("#selectedDone").hide();
		  $("#changeSelected").show();
		  $("#div_delivery").focus();
		}else{
			 $("#shoppingCatTb1").show();
			 $("#shoppingCatTb2").hide();
			 hideDiv();
			 $("#select_prod").show();
			 $("#selectedDone").show();
			 $("#changeSelected").hide();
		   $("#select_prod").focus();
		}
	}

	function showDiv(){
		$("#div_delivery").show();
		$("#div_nml").hide();
		$("#div_dpn").hide();
		$("#div_invoice").show();
		$("#div_vrtlblnc").show();
		$("#div_payway").show();
		<%--选择配送方式若只有一种时，预先选取并选好配送地址--%>
		<c-rt:if test="${not resultDaphne}">
			$(":input[name=delivery][type=radio][value=nml]").click();
		</c-rt:if>
	}

	function hideDiv(){
		$("#div_delivery").hide();
		$("#div_nml").hide();
		$("#div_dpn").hide();
		$("#div_invoice").hide();
		$("#div_vrtlblnc").hide();
		$("#div_payway").hide();
	}

	<%--获得所有选中的product spec,如果有多件,那么就会出现多次--%>
	function loadAllProductSpecs() {
		var products = new Array();
		$("#prodList tr").each(function () {
	    try {
	      var id = $(this).attr("id");
	      id = id.split("_")[1];
	      if (id) {
	        var count = $("#pQty_" + id).val();
	        var loopNum = parseInt(count);
	        for (var i = 0; i < loopNum; i++) {
          	products.push(id);
	        }
	      }
	    } catch (e) {
	      alert(e);
	    }
		});
		return products;
	}

	<%--判断是否超过限制--%>
	function fireAlarm(products) {
    if (products.length <= 0) {
      alert('请选择要购买的商品');
      return false;
    }
    return true;
	}
	<%--查詢province ajax--%>
	function queryProvince2(adCity,adDistrict){
		var province=$("#province").find('option:selected').val();
		if ( "" != province ){
			$.ajax({
			    url: '${frontContextPath}/shopping/addressdata/findProductCitys.do',
			    type: 'post',
			    dataType: 'json',
			    data: {ss:'${ss}',id:'${st.productId}',province:province},
			    cache: false,
			    beforeSend: function(xhr) {
			    	var options = '<option value="">资料载入中...</option>';
			    	$("#city").html(options);
		    	},
			    success: function( actionResult ){
			    	addressObj(actionResult,'CITY',adCity,adDistrict);
			    	setTimeout('settingReceiverData()',1);
				}
			});
		}
	}
	
	<%--查詢city ajax--%>
	function queryCity2(adDistrict){
		var city=$("#city").find('option:selected').val();
		$.ajax({
		    url: '${frontContextPath}/shopping/addressdata/findProductDistricts.do',
		    type: 'post',
		    dataType: 'json',
		    data: {ss:'${ss}',id:'${st.productId}',city:city},
		    cache: false,
		    beforeSend: function(xhr) {
		    	var options = '<option value="">== 选择地区 ==</option>';
					$("#district").html(options);
	    	},
		    success: function( actionResult ){
		    	addressObj(actionResult,'DISTRICT','',adDistrict);
		    	setTimeout('settingReceiverData()',1);
			}
		});
	}

	<%--Province&City 查詢元件--%>
	function addressObj(actionResult,execObj,adCity,adDistrict){
		if(actionResult!=null ){
			var arr_text = actionResult.split("$");		
			if(execObj=='CITY'){								
				var options = '<option value="">== 选择城市 ==</option>';
			}
			if(execObj=='DISTRICT'){
				var options = '<option value="">== 选择地区 ==</option>';
			}
			 for(i=0;i<arr_text.length;i++)
			 {
				 v=arr_text[i].split(",");
				 if(execObj=='CITY'){	
					options += '<option value="' + v[1] + '">' + v[1] + '</option>';
				 }
				if(execObj=='DISTRICT'){
					options += '<option value="' + v[1]+','+v[2]+','+v[3] +','+v[4] + '">' + v[1] + '</option>';
				}
			 }
			 var aObj;
			 if(execObj=='CITY'){	
				 $("#city").html(options);
				 aObj=$("#city");
			 }
			 if(execObj=='DISTRICT'){
				 $("#district").html(options);
				 aObj=$("#district");
			 }
				 aObj[0].selectedIndex = 0 ; 
				var tmpObj;
				if(execObj=='CITY'){	
					tmpObj=adCity;
				 }
				 if(execObj=='DISTRICT'){
					 tmpObj=adDistrict;
				 }
				 if(tmpObj !=""){
					 aObj.children().each(function(index){
						 if(execObj=='CITY'){	
							 if ($(this).text()==adCity){
							       setTimeout(function() {  aObj[0].selectedIndex = index ; 
							       queryCity2(adDistrict);} , 1);
							    }
							 }
							 if(execObj=='DISTRICT'){
								 if ($(this).text().substring(1)==adDistrict || $(this).text() == adDistrict){
								   setTimeout(function() {  $("#district")[0].selectedIndex = index ;
								   queryDistinct();},1);
								 }
							 }
					 });
				 }
		}
	}

	<%--查詢distinct ajax--%>
	function queryDistinct(){
		var districtVal = $("#district").find('option:selected').val();
		var districtTxt = $("#district").find('option:selected').text();
		var dtVal=districtVal.split(",");
		if(districtTxt.substring(0,1)=='※'){
			$("#version").val(dtVal[2]);
		}
		setTimeout('settingReceiverData()',1);
	}
	
	function ccodeCallback(ccodeResult){
 		if(ccodeResult == "error"){
 			$("#ccode").focus();	
			$("#codeTip").html('验证码错误，请重新输入');
			$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
			$("#codeTip").show();
			return false;
		}else{
			$.ajax({
				beforeSend: function(){
					$("#loadingData").dialog("open");
					$.post("${frontContextPath}/shopping/tuangou/jsonPaymentInfoByTuangou.do?ss=${ss}",$("#paymentInfoByTuangouForm").serialize(),tuangouCallback,"json");
				},	
				cache: false,
				success:　function(){
					$("#loadingData").dialog("close");
				}
			}); 
			
		}
	}

	function tuangouCallback(paymentInfoResult){
		var resultArray = paymentInfoResult.split("＠");
		if ( paymentInfoResult.indexOf("ok") != -1 ){
			location.href=resultArray[1];
		}else{
			$("#" + resultArray[0]).text(resultArray[1]);
			$("#" + resultArray[0]).focus();
			$("#" + resultArray[0]).show();
			$("#ccode").val("");
			$("#iv").attr("src","${frontContextPath}/servlet/imageValid.jpg?"+Math.random());
		}
	}

	function saveInput(text, abId, iName, iProvince, iCity, iDistrict, iStreet, iZip, iMobile, iAreaCode, iPhone, iExte,iEmail,iChkBtn){
		var inputCorrect = true;
		var a_msg = new Array();
		a_msg[0]="true";
		a_msg[1]="";
		if(iName == "" || iName == "(请输入收货人姓名)"){
			a_msg[0]="false";
			a_msg[1]="请输入收件人姓名";
		}
		if(numberCount(iName)>0){
			a_msg[0]="false";
			a_msg[1]="不允许数字输入";
		}		
		if ( iChkBtn == "nml" ){
			a_msg[2]="";
			if(iProvince == ""){
				a_msg[0]="false";
				a_msg[2]="请选择省";
			}
			if(iCity == ""){
				a_msg[0]="false";
				a_msg[2]="请选择城市";
			}		
			if(iDistrict == ""){
				a_msg[0]="false";
				a_msg[2]="请选择地区";
			}			
			if(iZip == ""){
				a_msg[0]="false";
				if(a_msg[2].length!=0){a_msg[2]+="，";}
				a_msg[2]="请输入邮编";
			}
			if(iStreet == "" || iStreet == "(输入街道地址，例如：和平路12巷52号)"){
				a_msg[0]="false";
				if(a_msg[2].length!=0){a_msg[2]+="，";}
				a_msg[2]="请输入街道";
			}
			if(iStreet.length >100){
				a_msg[0]="false";
				a_msg[2]="街道过长";
			}		
			if(chineseCount(iStreet)==0){
				a_msg[0]="false";
				a_msg[2]="不允许全部数字输入";
			}	
		}else if ( iChkBtn == "dpn" ){
			a_msg[4]="";
			if ( $("#storeArea").find('option:selected').val() == "" ){
				a_msg[0]="false";
				a_msg[4]="请选择区域";
			}
			a_msg[5]="";
			if ( $("#storeImage").find('option:selected').val() == "" ){
				a_msg[0]="false";
				a_msg[5]="请选择地址";
			}			
		}
		a_msg[3]="";
		if(trim(iMobile)=="" && trim(iPhone)==""){
			a_msg[0]="false";
			a_msg[3]="请至少填写一组电话";
		}
		if(iPhone!="" && iAreaCode==""){
			a_msg[0]="false";
			a_msg[3]="请输入区码";
		}
		if(iAreaCode!= "" && isNaN(parseInt(trim(iAreaCode), 10))==true && trim(iAreaCode) !=""){
			a_msg[0]="false";
			a_msg[3]="固定电话区码请使用半角数字";
		}
		if(iPhone!= "" && isNaN(parseInt(trim(iPhone), 10))==true && trim(iPhone) !=""){
			a_msg[0]="false";
			a_msg[3]="固定电话请使用半角数字";
		}		
		if(iExte!= "" && isNaN(parseInt(trim(iExte), 10))==true && trim(iExte) !=""){
			a_msg[0]="false";
			a_msg[3]="固定电话分机请使用半角数字";
		}				
		if(iMobile != "" && trim(iMobile).length >=1 &&trim(iMobile).length <9){
			a_msg[0]="false";
			a_msg[3]="手机号码至少要九码";
		}		
		if(iMobile != "" && isNaN(parseInt(trim(iMobile), 10))==true && trim(iMobile) !=""){
			a_msg[0]="false";
			a_msg[3]="手机号码请使用半角数字";
		}
		<c-rt:if test="${member.sendEmail=='xx'}">
  		if(iEmail == "xx"){
				a_msg[0]="false";
  			a_msg[6]="请输入联络邮箱";
   		}else if(iEmail.match(/.+@.+\..+/)==null || iEmail.indexOf(' ')>=0 || chineseCount(iEmail)>0){
    		if(jQuery.trim(iEmail)==''){
					a_msg[0]="false";
	  			a_msg[6]="请输入联络邮箱";
    		}else{
					a_msg[0]="false";
	  			a_msg[6]="邮箱格式错误";        		
   			}
   		}
		</c-rt:if>		
		if(a_msg[0]=="true"){
			return null;
		}else{
			return a_msg;
		}
	}	

	<%--检核收货人资料--%>
	function chkReceiverData(chkBtn){
		var thisVal = "";
		var inputResult = "";
		if ( chkBtn == "nml" ){
			inputResult = saveInput("", -1, $("#contactName").val(),$("#province").val(),$("#city").val(),$("#district").val(),$("#addr").val(),$("#zipCode").val(),$("#mobile").val(),$("#areaCode").val(),$("#phone").val(),$("#extension").val(),$("#mail").val(),chkBtn);
		}else{
			thisVal = chkBtn + "_";
			inputResult = saveInput("", -1, $("#dpn_contactName").val(),"上海","上海市",$("#dpn_district").val(),$("#dpn_addr").val(),$("#dpn_zipCode").val(),$("#dpn_mobile").val(),$("#dpn_areaCode").val(),$("#dpn_phone").val(),$("#dpn_extension").val(),$("#dpn_mail").val(),chkBtn);
		}
		$("#" + thisVal + "contactNameTip").hide();
		$("#" + thisVal + "addrTip").hide();
		$("#" + thisVal + "telTip").hide();
		$("#" + thisVal + "provinceTip").hide();
		$("#" + thisVal + "addrTip").hide();
		$("#" + thisVal + "mailTip").hide();
		$("#storeAreaTip").hide();
		$("#storeImageTip").hide();
		if(inputResult!=null && inputResult[0]=="false"){
			if(inputResult[1]!=""){
				$("#" + thisVal + "contactNameTip").text(inputResult[1]);
				$("#" + thisVal + "contactNameTip").show();
			}
			if(inputResult[2]!=""){
				$("#" + thisVal + "addrTip").text(inputResult[2]);
				$("#" + thisVal + "addrTip").show();
			}
			if(inputResult[3]!=""){
				$("#" + thisVal + "telTip").text(inputResult[3]);
				$("#" + thisVal + "telTip").show();
			}	
			if(inputResult[4]!=""){
				$("#storeAreaTip").text(inputResult[4]);
				$("#storeAreaTip").show();
			}	
			if(inputResult[5]!=""){
				$("#storeImageTip").text(inputResult[5]);
				$("#storeImageTip").show();
			}	
			if(inputResult[6]!=""){
				$("#" + thisVal + "mailTip").text(inputResult[6]);
				$("#" + thisVal + "mailTip").show();
			}									
		}else{
			settingReceiverData();
			$("#" + thisVal + "show_receiver_addr").parent().parent().show();
			$("#" + thisVal + "edit_receiver_addr").hide();
			$("#myAddBook").focus();
		}		
	}

	<%--取消收货人资料--%>
	function cancelReceiverData(cancelBtn){
		var thisVal = "";
		if ( cancelBtn == "dpn" ){
			loadDpnData();
		}
		if ( cancelBtn == "nml" ){
			loadNmlData();
		}
		
		if ( cancelBtn == "dpn" ){
			thisVal = cancelBtn + "_";
		}
		if ( $("#" + thisVal + "show_receiver_addr").val() == "" && $("#" + thisVal + "show_receiver_addr").html() == ""){
			alertDialog('请填写收货人信息', '请填写收货人信息');
		}
		$("#" + thisVal + "show_receiver_addr").parent().parent().show();
		$("#" + thisVal + "edit_receiver_addr").hide();
	}

	<%--将收货人资料放入要送出的栏位中--%>
	function settingReceiverData(){
		if ( $('input[name=delivery]').is(":checked") ){
			var thisVal = $('input[name="delivery"]:checked').val();
			if ( thisVal == "nml" ) thisVal = "";
			if ( thisVal == "dpn" ) thisVal = thisVal + "_";
			$("#editcontactName").val($("#" + thisVal + "contactName").val());
			$("#editareaCode").val($("#" + thisVal + "areaCode").val());
			$("#editphone").val($("#" + thisVal + "phone").val());
			$("#editextension").val($("#" + thisVal + "extension").val());
			$("#editmobile").val($("#" + thisVal + "mobile").val());
			if ( thisVal.indexOf("dpn") != -1 ){
				$("#editprovince").val("上海");
				$("#editcity").val("上海市");
				$("#editdistrict").val($("#" + thisVal + "district").val());
			}else{
				$("#editprovince").val($("#" + thisVal + "province").find('option:selected').text());
				$("#editcity").val($("#" + thisVal + "city").find('option:selected').text());
				$("#editdistrict").val($("#" + thisVal + "district").find('option:selected').text());				
			}
			$("#editzipCode").val($("#" + thisVal + "zipCode").val());
			$("#editaddr").val($("#" + thisVal + "addr").val());
			$("#editmail").val($("#" + thisVal + "mail").val());
			showReceiverData();
		}
	}

	<%--清空要送出的收貨人資料--%>
	function initReceiverData(){
		$("#editcontactName").val("");
		$("#editareaCode").val("");
		$("#editphone").val("");
		$("#editextension").val("");
		$("#editmobile").val("");
		$("#editprovince").val("");
		$("#editcity").val("");
		$("#editdistrict").val("");
		$("#editzipCode").val("");
		$("#editaddr").val("");
		$("#editmail").val("");
		<c-rt:if test="${member.sendEmail!='xx'}">
			$("#editmail").val("${member.sendEmail}");
		</c-rt:if>
	}

	<%--載入快遞資料--%>
	function loadNmlData(){
		$.getJSON("${frontContextPath}/shopping/tuangou/findLastAddBook.do?type=json&ss=${ss}",{type:'product',id:'${st.productId}'}
		,function(addBookDataJson){
			<c-rt:if test="${resultDaphne}">
				clearDpnData();
			</c-rt:if>
			if ( null == addBookDataJson ){
				$("#show_receiver_addr").parent().parent().hide();
				$("#edit_receiver_addr").show();
			}else{
				$("#contactName").val(addBookDataJson.contactName).css("color","#000");
				$("#addr").val(addBookDataJson.addr).css("color","#000");
				$("#zipCode").val(addBookDataJson.zipCode);								
				if(addBookDataJson.mobile==null){
					$("#mobile").val("");
				}else{
					$("#mobile").val(trim(addBookDataJson.mobile));
				}
				if(addBookDataJson.areaCode==null){
					$("#areaCode").val("");
				}else{
					$("#areaCode").val(addBookDataJson.areaCode);
				}
				if(addBookDataJson.phone==null){
					$("#phone").val("");
				}else{
					$("#phone").val(trim(addBookDataJson.phone));
				}
				if(addBookDataJson.extension==null){
					$("#extension").val("");
				}else{
					$("#extension").val(addBookDataJson.extension);
				}
				$("#province").children().each(function(index){
					if (trim($(this).text()) == trim(addBookDataJson.province)){
						$("#province")[0].selectedIndex = index ;
						queryProvince2(addBookDataJson.city,addBookDataJson.district);
					}
				});
				var tmpCity=$("#city").find('option:selected').val();
				var tmpDistrict=$("#district").find('option:selected').text();
				<%--计算运费(团购商品目前免运--%>
				var tmpProvince=$("#province").find('option:selected').val();
				var tmpFinalMustPay=$("#editTotalAmount").val();
				//caleShipFare(tmpProvince,tmpIsBuyNow,tmpFinalMustPay,addCmpPd,buyNowCartId);
			}
		});
	}

	function showReceiverData(){
		if ( $('input[name=delivery]').is(":checked") ){
			var thisVal = $('input[name="delivery"]:checked').val();
			if ( thisVal == "nml" ) thisVal = "";
			if ( thisVal == "dpn" ) thisVal = thisVal + "_";
			$("#" + thisVal + "show_receiver_addr").html("");
			$("#" + thisVal + "show_receiver_addr").append($("#editcontactName").val()).append(",")
			.append($("#editzipCode").val()).append(",")
			.append($("#editprovince").val()).append(",")
			.append($("#editcity").val()).append(",")
			.append($("#editdistrict").val()).append(",")
			.append($("#editaddr").val()).append(",")
			.append($("#editareaCode").val()).append(",")
			.append($("#editphone").val()).append(",")
			.append($("#editextension").val()).append(",")
			.append($("#editmobile").val()).append(",")
			.append($("#editmail").val());
		}
	}

	<%--清除快遞資料--%>
	function clearNmlData(){
		$("#addrTip").text("");
		$("#contactName").val("");
		$("#contactNameTip").text("");
		$("#areaCode").val("");
		$("#phone").val("");
		$("#extension").val("");
		$("#mobile").val("");
		$("#province").selectedIndex = 0;
		$("#city").selectedIndex = 0;
		$("#district").selectedIndex = 0;
		$("#zipCode").val("");
		$("#addr").val("");		
		$("#telTip").val("");
		$("#mobileTip").val("");
		$("#mail").val("");
		$("#mailTip").val("");
		initReceiverData();
	}	
	
	<c-rt:if test="${resultDaphne}">
	<%--清除達芙妮資料--%>
	function clearDpnData(){
		$("#storeArea").selectedIndex = 0;
		$("#storeAreaTip").text("");
		$("#storeImage").selectedIndex = 0;
		$("#storeImageTip").text("");
		$("#dpn_contactName").val("");
		$("#dpn_contactNameTip").text("");
		$("#dpn_areaCode").val("");
		$("#dpn_phone").val("");
		$("#dpn_extension").val("");
		$("#dpn_mobile").val("");
		$("#dpn_province").val("");
		$("#dpn_city").val("");
		$("#dpn_district").val("");
		$("#dpn_zipCode").val("");
		$("#dpn_addr").val("");		
		$("#dpn_telTip").val("");
		$("#dpn_mobileTip").val("");
		$("#dpn_mail").val("");
		$("#dpn_mailTip").val("");
		initReceiverData();
	}
	
	<%--載入達芙妮資料--%>
	function loadDpnData(){
		clearNmlData();
		if ( $("#receiverData").val() == "" ){
			$("#dpn_show_receiver_addr").parent().parent().hide();
			$("#dpn_edit_receiver_addr").show();
		}else{
			var receiverDataAy=$("#receiverData").val().split(",");
			if(receiverDataAy[0] != ''){
				$("#dpn_contactName").val(receiverDataAy[0]).css("color","#000");
			}
			if(receiverDataAy[1] != ''){
				$("#dpn_areaCode").val(receiverDataAy[1]);
			}
			if(receiverDataAy[2] != ''){
				$("#dpn_phone").val(receiverDataAy[2]);
			}
			if(receiverDataAy[3] != ''){
				$("#dpn_extension").val(receiverDataAy[3]);
			}
			if(receiverDataAy[4] != ''){
				$("#dpn_mobile").val(receiverDataAy[4]);
			}
			if($("#dpn_contactName").val()==''){
				$("#dpn_contactName").val("(请输入收货人姓名)").css("color","#aaa")};
	
			$("#dpn_contactName").focus(function(){
				if($("#dpn_contactName").val()=='(请输入收货人姓名)'){
				$("#dpn_contactName").val("").css("color","#000")};
			}).blur(function(){
				if($("#dpn_contactName").val()==''){
				$("#dpn_contactName").val("(请输入收货人姓名)").css("color","#aaa")};
			});
	
			if($("#dpn_addr").val()!='' && $("#dpn_addr").val()!='(请选择门市地址)'){
				$("#dpn_addr").val($("#storeImage").find('option:selected').text());
				$("#dpn_district").val($("#storeArea").find('option:selected').text());
			};
		}
	}

	function storeAreaSelected(storeAreaInit){
		 var storeArea = storeAreaInit;
		 var storeId =$("#storeId").val();
			$.post("${frontContextPath}/shopping/orderInfo/findDaphnes.do?ss=${ss}",{storeArea:storeArea},callback,"json");
			function callback(actionResult){
				if(actionResult!=null){
				  var arr_text = actionResult.split("$");										
					var options = '<option value="">请选择</option>';
					for(i=0;i<arr_text.length;i++){
						v=arr_text[i].split(",");
						if(storeId == v[0]){
							options += '<option value="' + v[0] + '" selected="selected">' + v[1] + '</option>';
						}else{
							options += '<option value="' + v[0] + '">' + v[1] + '</option>';	
						}	
					}
					$("#storeImage").html(options);
					if(storeId == ""){
						$('#storeImage option:first').attr('selected', 'selected');
					}else{
						$("#imagePreview").html(storeId ? "<img src='/images/daphne/" + storeId + ".jpg'>" : "<img src='/images/daphne/000.gif'>");
						$("#pickStore").html("上海市，"+$("#storeArea").find('option:selected').text()+"，"+$("#storeImage").find('option:selected').text());
						$("#dpn_addr").val($("#storeImage").find('option:selected').text());
						$("#dpn_district").val($("#storeArea").find('option:selected').text());
					}
				}	
			}
	}	
	</c-rt:if>
	
	function numberCount(word){
    var length=0;
    for(var cc=0;cc<word.length;cc++){
       var c = word.charCodeAt(cc);
      if ((c>=48&&c<=57)) length++;
    }
    return length;
	}
	function chineseCount(word){
    var length=0;
    for(var cc=0;cc<word.length;cc++){
       var c = word.charCodeAt(cc);
      if (!(c>=32&&c<=126)) length++;
    }
    return length;
	}
	<%--去除字串左邊的空白虛格--%>
	function ltrim(instr){
		return instr.replace(/^[\s]*/gi,"");
	}

	<%--去除字串右邊的空白虛格--%>
	function rtrim(instr){
		return instr.replace(/[\s]*$/gi,"");
	}

	<%--去除字串前後的空白虛格--%>
	function trim(instr){
		instr = ltrim(instr);
		instr = rtrim(instr);
		return instr;
	}		

	<%--初始化账户余额--%>
	function initWallet(){
		$("#useWallet").hide();
		$("#subVrtlBlnc").attr("readOnly", true); 
		$("#subVrtlBlnc").css("background-color","silver");
		$("#allpaymsg").hide();    	
		$("#chkVrtBlnc").attr('checked', false);
		$("#chkVrtBlnc").val(0.0);  
   	$("#subVrtlBlnc2").val(0.0);
 		$("#subVrtlBlnc").val("");
    ProcessCalcuTotal();
		if(parseFloat($("#finalTotalAmount").val())!=0){
			$("input[id*='paytype']").each(function(i){
				if(this.id=='paytype40'){
					$(this).attr("disabled", true);
					$(this).attr("checked", false);
				}else{
					$(this).attr("disabled", false);
				}
			});
			$('input[name=bankCode]').attr("checked",false);
			$('input[name=bankCode]').attr("disabled",false);
			$('input[name=paytype][value=70]').attr("checked",false);
			$('input[name=paytype][value=70]').attr("disabled",false);
		}    
	}	
	<%--初始化礼品卡余额--%>
	function initGiftCard(){
		$("#useGiftCard").hide();
		$("#subGiftCard").attr("readOnly", true); 
		$("#subGiftCard").css("background-color","silver");
		$("#allpaymsg").hide();    	
		$("#chkGiftCard").attr('checked', false);
		$("#chkGiftCard").val(0.0);  
   	$("#subGiftCard2").val(0.0);
 		$("#subGiftCard").val("");
    ProcessCalcuTotal();
    if(parseFloat($("#finalTotalAmount").val())!=0){
			$("input[id*='paytype']").each(function(i){
				if(this.id=='paytype40'){
					$(this).attr("disabled", true);
					$(this).attr("checked", false);
				}else{
					$(this).attr("disabled", false);
				}
			});
			$('input[name=bankCode]').attr("checked",false);
			$('input[name=bankCode]').attr("disabled",false);
			$('input[name=paytype][value=70]').attr("checked",false);
			$('input[name=paytype][value=70]').attr("disabled",false);
		}    
	}	

	<%--初使化订单金额(商品总额)--%>
	<%--应付金额计算--%>
	function ProcessCalcuTotal(){
		if ( $("#chkVrtBlnc").attr("checked") &&  $("#useWallet").is(':hidden') ){
			if ( "" == $("#subVrtlBlnc").val() ){
				$("#pVirtualBalance").text(parseFloat(0).toFixed(1));
			}else{
				$("#pVirtualBalance").text(parseFloat($("#subVrtlBlnc").val()).toFixed(1));<%--付款方式-账户余额--%>
			}
		}else{
			$("#pVirtualBalance").text(parseFloat(0).toFixed(1));
		}
		if ( $("#chkGiftCard").attr("checked") &&  $("#useGiftCard").is(':hidden') ){
			if ( "" == $("#subGiftCard").val() ){
				$("#pGiftCard").text(parseFloat(0).toFixed(1));
			}else{
				$("#pGiftCard").text(parseFloat($("#subGiftCard").val()).toFixed(1));<%--付款方式-礼品卡余额--%>
			}
		}else{
			$("#pGiftCard").text(parseFloat(0).toFixed(1));
		}
		var finalTotalAmount = parseFloat($("#editTotalAmount").val()) - parseFloat($("#subVrtlBlnc2").val()).toFixed(1) - parseFloat($("#subGiftCard2").val()).toFixed(1);
		$("#pTotalAmount").text(parseFloat($("#editTotalAmount").val()).toFixed(1));<%--商品金额--%>
		$("#tempTotalAmount").val(finalTotalAmount);<%--付款方式-订单金额--%>
		if ( parseFloat(finalTotalAmount) >= 0 ){
			$("#pFinalTotalAmount").text(finalTotalAmount);<%--付款方式-订单金额--%>
			$("#finalTotalAmount").val(finalTotalAmount);
		}
	}
</script>
<c-rt:if test="${!haveInventory}"><c-rt:set var="noinv" value="txt-gy"/></c-rt:if>
<c-rt:if test="${product.productType!='6'}">
<div class="payment-box" id="select_prod">
  <h3>您选择的商品如下</h3>
	<input type="hidden" id="major" name="major" value=""/>
	<input type="hidden" id="spec" name="spec" value=""/>
	<div class="select-area">
		<p class="pdtype-main"><strong>${product.mainCodeLabel}：</strong><em id="msem1"></em><br />	
			<c-rt:forEach items="${product.specMajors}" var="specMajor" varStatus="status">
			<c-rt:if test="${specMajor.isDelete eq 'N'}">
		 		<a class="pd-type" href="javascript:;" onclick="selectProdMainSpec('${specMajor.mainSpecId}');" id="ms_${specMajor.mainSpecId}" title="${specMajor.mainSpecName}"><img src="${specMajor.imgIcon}" onError="this.src='${imgDomain}/PImg/40x40.gif'" width="40" height="40" />${specMajor.mainSpecName}</a>
	 		</c-rt:if>
	 		</c-rt:forEach>
	   </p>
	   <p><strong>${product.secondCodeLabel}：</strong><em id="ssem1"></em><br />
	   	<div id="secSpecArea"></div>
	   </p>
	   <p><strong>数量：</strong>
	     <select name="qty" id="qty" class="${noinv}"></select>
		 </p>
		 <p class="payment-confirm">
	     <a href="javascript:void(0);" class="btn-mid" id="saveToCart">确认</a>
	     <span id="mainCodeLabel" style="display:none;"><span class="msg rn">请选择${product.mainCodeLabel}</span></span>
	     <span id="secondCodeLabel" style="display:none;"><span class="msg rn">请选择${product.secondCodeLabel}</span></span>
	   </p>
	</div>
</div>
<form id="paymentInfoByTuangouForm" method="post">
<div class="payment-box" id="div_plist" style="display:none;">
	<h3>请选择颜色尺码</h3>
 	<table cellspacing="0" cellpadding="0" class="tgprod-table" id="shoppingCatTb1">
  	<thead class="tgprod-th">
     <tr>
       <td>${product.mainCodeLabel}</td>
       <td>${product.secondCodeLabel}</td>
       <td>单价</td>
       <td>数量</td>
       <td>小计</td>
       <td>操作</td>
      </tr>
    </thead>
    <tbody id="prodList">
    </tbody>
    <tfoot>
    	<tr>
       	<td class="tgprod-total" colspan="7">
           <span>商品数量总计：<em id="spTotalCount">0</em>件</span>
           <span>商品金额总计：￥<em id="spTotalAmount">0</em>元</span>
         </td>
      </tr>
    </tfoot>
  </table>  
 	<table cellspacing="0" cellpadding="0" class="tgprod-table" id="shoppingCatTb2" style="display:none;">
  	<thead class="tgprod-th">
     <tr>
       <td>${product.mainCodeLabel}</td>
       <td>${product.secondCodeLabel}</td>
       <td>单价</td>
       <td>数量</td>
       <td>小计</td>
       <td>操作</td>
      </tr>
    </thead>
    <tbody id="prodList2">
    </tbody>
    <tfoot>
    	<tr>
       	<td class="tgprod-total" colspan="7">
           <span>商品数量总计：<em>0</em>件</span>
           <span>商品金额总计：￥<em>0</em>元</span>
         </td>
      </tr>
    </tfoot>
  </table>  
  <p class="payment-confirm step2">
  	<input type="hidden" value="" name="productsArray" id="productsArray" data-val-required="请选择要购买的商品！" data-val="true">
  	<input type="hidden" value="${st.tuangouId}" id="tuangouId" name="tuangouId"/>
  	<a href="javascript:void(0);" class="btn-mid" id="selectedDone" onclick="selectedDone();">选好了</a>
  	<a href="javascript:void(0);" class="btn-mid" id="changeSelected" onclick="changeSelected();" style="display:none;">改一改</a>
  	<span id="qtyNotEnoughTip" style="display:none;float:right;" class="msg rn"></span>
  </p>
</div>
<div class="payment-box" id="div_delivery" style="display:none;">
	<h3>选择配送方式</h3>
	<ul>
		<c-rt:if test="${resultDaphne}">	
	  	<li class="w-pay"><label><input type="radio" name="delivery" value="dpn"><span>达芙妮门店取货&nbsp;(限定上海全区)</span></label></li>
	  </c-rt:if>
	  <li class="w-pay"><label><input type="radio" name="delivery" value="nml"><span>一般快递或是EMS邮政</span>快递</label></li>
	</ul>
</div>
<div class="payment-box" id="div_nml" style="display:none;">
 <h3>选择配送地址 <span><a href="javascript:void(0);" id="myAddBook">从收货地址簿选取</a></span></h3>
  <ul>
    <li class="w-pay"><label><span id="show_receiver_addr"></span></label><a title="修改" href="javascript:void(0);" onclick="editReceiverAddr('nml');" class="data-edit">修改</a></li>
    <li class="w-pay" id="edit_receiver_addr" style="display:none;">
    <div class="consignee">
    <!-- 收货人 -->
    <h4>收货人信息<span>(<b class="txt-rd">*</b>为必填项目)</span></h4>
    <ul>
      <li class="w-1of1"><label for="name"><span class="txt-rd">*</span> 姓名：</label>
      <span><input class="txt-gy" id="contactName" value="${lastAddressBook.contactName}" maxlength="20" size="15">
      <br><span id="contactNameTip" style="margin-left:7.9em;*margin-left:0;" class="msg rn">请填写姓名</span> 
      </span>
      </li>
      <li class="w-1of1">
      	<div><label><span class="txt-rd">*</span> 地    址：</label></div>
        <div>
        	省份：
        	<select class="c-prov" id="province">
        		<option value="">== 选择省 ==</option>
						<c-rt:forEach items="${provincesMap}" var="province" >
							<option value="${province.key}">${province.key}</option>
						</c-rt:forEach>
        	</select>
        	市：<select id="city">
            	<option value="">== 选择城市 ==</option>
            </select>
 					区：<select id="district">
              <option value="">== 选择地区 ==</option>
            </select>
          <br/><span id="provinceTip" class="msg rn"></span>
          <c-rt:if test="${not empty prodVolumeMap}">
          <p class="bigsize-txt"><strong>提醒您：</strong>订购的部份商品为<span class="txt-rd">大材积</span>，仅显示该商品能配送到达的地址。
          	<a href="#">查看大材积商品</a>
          </p>
          <ul style="display:none;" id="arriveplace">
          	<s id="prodVolumeClose">X</s>
            <c-rt:forEach items="${prodVolumeMap}" var="prod">
	        		<li>${prod.value}</li>
	        	</c-rt:forEach>
          </ul>
          </c-rt:if>
          <p></p>
		      <br>
					邮编：<input type="text" id="zipCode" value="${lastAddressBook.zipCode}" size="6" maxlength="6"/>
					街道： <input size="50" class="txt-gy" type="text" id="addr" value="${lastAddressBook.addr}" size="50">
					<span id="addrTip" class="msg rn">请输入完整的联络地址</span>
        </div>
      </li>
      <li class="c-f">
        <label for="tel">固定电话：</label>
        <span>
        	<input type="text" id="areaCode" value="${lastAddressBook.areaCode}" size="5" maxlength="4">-
					<input type="text" id="phone" value="${lastAddressBook.phone}" size="10" maxlength="10" maxlength="8">- 分机
					<input type="text" id="extension" value="${lastAddressBook.extension}" size="4" maxlength="8">
        </span>&nbsp;
        <strong>手机号码：</strong>
        <input type="text" id="mobile"  value="${lastAddressBook.mobile}" size="18" maxlength="11">
        <span class="txt-ss">&nbsp;(<span class="txt-rd">*</span>固定电话与手机需至少填写一区)</span>
        <br/>
        <span id="telTip" class="msg rn">请至少填写一组电话</span>
      </li>
			<c-rt:if test="${member.sendEmail=='xx'}">
				<li class="c-f">
          <label for="tel"><span class="txt-rd">*</span>联络邮箱：</label>
           <input id="mail" value="" size="50" >
           <span class="txt-ss">&nbsp;(您将会透过此邮箱接收订单进度通知信)</span> 
           <br/>
           <span id="mailTip" class="msg rn" style="display:none;">请填联络邮箱</span>
       </li>
			</c-rt:if>   
   	</ul>
    <input type="button" value="取消" onclick="cancelReceiverData('nml');" class="default-btn">
    <input type="button" value="确认收货人信息" onclick="chkReceiverData('nml');" class="default-btn">
    </div>
   	</li>
  </ul>
</div>
<c-rt:if test="${resultDaphne}">
<div class="payment-box" id="div_dpn" style="display:none;">
	<h3>选择配送门市</h3>
  <ul>
  	<li class="w-pay"><label><span id="dpn_show_receiver_addr"></span></label><a title="修改" href="javascript:void(0);" onclick="editReceiverAddr('dpn');" class="data-edit">修改</a></li>
    <li class="w-pay" id="dpn_edit_receiver_addr" style="display:none;">
    	<h4>选择取货门店</h4>
    	<div class="atstore">
    		<div class="area01">
    			<p>目前达芙妮取货范围限定<strong>上海全区</strong></p>
					<p>
						<label>区域：</label>
						<select name="storeArea" id="storeArea">
							<option value="">请选择</option>
							<option value="卢湾区">卢湾区</option>
							<option value="普陀区">普陀区</option>
							<option value="青浦区">青浦区</option>
							<option value="松江区">松江区</option>
							<option value="宝山区">宝山区</option>
							<option value="长宁区">长宁区</option>
							<option value="虹口区">虹口区</option>
							<option value="黄浦区">黄浦区</option>
							<option value="闵行区">闵行区</option>
							<option value="南汇区">南汇区</option>
							<option value="闸北区">闸北区</option>
							<option value="奉贤区">奉贤区</option>
							<option value="金山区">金山区</option>
							<option value="嘉定区">嘉定区</option>
							<option value="杨浦区">杨浦区</option>
							<option value="静安区">静安区</option>
							<option value="浦东新区">浦东新区</option>
							<option value="徐汇区">徐汇区</option>
						</select>
            <span id="storeAreaTip" class="msg rn" style="margin-left:3.5em;*margin-left:3.75em;_margin-left:1.87em"></span>
          </p>
          <p>
          	<label>地址：</label>
						<select name="storeImage" id="storeImage">
            	<option value="">请选择</option>
            </select>            
            <span id="storeImageTip" class="msg rn" style="margin-left:3.5em;*margin-left:3.75em;_margin-left:1.87em"></span>
          </p>
         </div>
         <div class="area02">
         	<p>
         		<label>取货门店：</label>
            <span id="pickStore">未选取</span>
          </p>
					<p>
						<span id="imagePreview">
			   			<img src="/images/daphne/000.gif" />
						</span>		
					</p>
        </div>
      </div>         
      <h4>收货人信息 <span>(<b class="txt-rd">*</b>为必填项目)</span></h4>
      <div class="consignee">
      	<ul>
        	<li class="w-1of1">
            <label for="name"><span class="txt-rd">*</span> 姓名：</label>
            <span>
	            <input type="text"  class="txt-gy" id="dpn_contactName" value="" maxlength="20" size="16"/>
            </span>
						<br><span id="dpn_contactNameTip" style="margin-left:7.9em;*margin-left:0;" class="msg rn">请填写姓名</span>  
          </li>
          <li class="c-f">
            <label for="tel"><span class="txt-rd">* </span>固定电话：</label>
            <span>
            <input type="text" id="dpn_areaCode" value="" size="5" maxlength="4"/>
            -
            <input type="text" id="dpn_phone" value="" size="10" maxlength="10" maxlength="8"/>
            - 分机
            <input type="text" id="dpn_extension" value="" size="4" maxlength="8"/>
            </span>&nbsp;&nbsp;<strong><span class="txt-rd">*</span>手机号码：</strong>
            <input type="text" id="dpn_mobile"  value="" size="18" maxlength="11"/>
            <span class="txt-ss">&nbsp;(到货时，系统将以email及短信通知您取货时间。)</span>
            <br><span id="dpn_telTip" class="msg rn" style="margin-left:7.9em;*margin-left:0;">请填写固定号码</span>
            <br><span id="dpn_mobileTip" class="msg rn" style="margin-left:18em;*margin-left:18.6em;">请填写手机号码</span>
          </li>
					<c-rt:if test="${member.sendEmail=='xx'}">
						<li class="c-f">
							<label for="tel"><span class="txt-rd">*</span>联络邮箱：</label>
							<input id="dpn_mail" value="" size="50" >
							<span class="txt-ss">&nbsp;(您将会透过此邮箱接收订单进度通知信)</span> 
							<br/>
							<span id="dpn_mailTip" class="msg rn" style="display:none;">请填联络邮箱</span>
						</li>
					</c-rt:if>           
        </ul>
				<input type="hidden" id="dpn_province" value="上海"/>
       	<input type="hidden" id="dpn_city" value="上海市"/>
       	<input type="hidden" id="dpn_district" value=""/>        	
       	<input type="hidden" id="dpn_addr" value=""/>
				<input type="hidden" id="storeId" name="storeId" value="${storeId}"/>
				<input type="hidden" id="storeAreaInit" name="storeAreaInit" value="${storeAreaInit}"/>
				<input type="hidden" id="receiverData" name="receiverData" value="${receiverData}"/>
				<input type="button" value="取消" onclick="cancelReceiverData('dpn');" class="default-btn">
				<input type="button" value="确认配送门店信息" onclick="chkReceiverData('dpn');" class="default-btn">
       </div>
     </li>
  </ul>
</div>
</c-rt:if>
<div id="div_invoice" class="payment-box" style="display:none;">
	<h3>发票信息</h3>
	<ul>
		<li class="w-pay">
			<label><input id="invotype01" name="invotype" type="radio" value="01"><span>个人</span></label>
			<label><input id="invotype02" name="invotype" type="radio" value="02"><span>单位</span></label>
			<input size="20" type="text" name="invoTitle" id="invoTitle" value="" maxlength="40"/> 
		</li>
	</ul>
	<div class="paymentinvoice"> 
	  <p><strong>发票提醒</strong></p>
    <p class="bullet">普通发票因商品而异，随货寄送或于订单签收后10个工作日寄出。</p>
    <p class="bullet">企业客户若需增值税专用发票，<a title="发票开具说明	" target="_blank" href="/help/7_invoice.html">请向客服申请开立增值税发票。</a></p>
  </div>
</div>
<div id="div_vrtlblnc" class="payment-box" style="display:none;">
	<h3>您可以用账户余额支付</h3>
	<ul>
		<li class="w-pay">
			<input id="chkGiftCard" name="chkGiftCard" type="checkbox" value="0.0"> 用我的礼品卡 
		  <input size="8" id="subGiftCard" name="subGiftCard"  value="" class="txt-rd" style="background-color:silver" readOnly /> 
		  元来支付 / 目前我的礼品卡余额为<strong>￥<span id="myGiftCardBalance">${member.balance.giftcardBalance}</span>元</strong>
		  <span id="useGiftCard" style="display:none;"><input type="button" id="confirmGiftCard" value="确认使用" name=""></span>
		</li>	
		<li class="w-pay">
			<input id="chkVrtBlnc" name="chkVrtBlnc" type="checkbox" value="0.0"> 用我的账户余额
      <input size="8" id="subVrtlBlnc" name="subVrtlBlnc"  value="" class="txt-rd" style="background-color:silver" readOnly />
      元来支付/目前我的账户余额为<strong>￥<span id="myVirtualBalance">${member.balance.virtualBalance}</span>元</strong>
     	<span id="useWallet" style="display:none;"><input type="button" id="confirmWallet" value="确认使用"/></span>
		</li>
		<li class="w-1of1 pad-1">订单金额：<strong class="txt-rd">￥ <span id="pFinalTotalAmount">0.0</span> 元</strong>(＝商品合计金额<strong> <span id="pTotalAmount">0.0</span> 元</strong> - 礼品卡<span id="pGiftCard">0.0</span>元  - 账户余额 <span id="pVirtualBalance">0.0</span>元)</li>
	</ul>
</div>
<div id="div_payway" class="payment-box" style="display:none;">
 <h3>您可以选择用银行卡或信用卡</h3>
  <div class="pay-way">
    <ul>
      <li class="w-pay"><strong>请选择付款方式：</strong>
      <span id="chkPayTypeTip" style="display:none;float:none;margin-bottom:1em;"><span class="msg rn">请选择支付方式</span></span><br>
			<div style="display:none;"><input id="paytype40" name="paytype" type="radio" value="40">  <strong>全额由我的账户余额或礼券付清</strong></div>
      <div id="allpaymsg" style="display:none;"><strong class="txt-rd">本订单已由「账户余额」付清全额，您不需再选择付款方式。</strong></div>      
      <div><strong>网上支付</strong></div>
      <c-rt:choose>
      	<c-rt:when test="${member.applySource eq 'taobaomember'}">
      		<div><p><strong>第三方支付：</strong></p></div>
			 		<div class="sub-bank bankers">
			 			<label><input type="radio" name="bankCode" value="alipay"><span><img width="100" height="30" src="/images/bank/third01.gif" alt="支付宝"></span></label>
			 		</div>
      	</c-rt:when>	
      	<c-rt:when test="${member.applySource eq 'alipaymember'}">
      		<div><p><strong>银行支付：</strong></p></div>
      		<div class="sub-bank bankers">
				 		<c-rt:forEach items="${bankCodeMenu.options}" var="bcm" varStatus="m">
				 			<label><input type="radio" name="bankCode" value="${bcm.key}"><span><img width="100" height="30" src="/images/bank/${bcm.key}.gif" alt="${bcm.value.name}"/></span></label>
				 		</c-rt:forEach>
			 		</div>
			 		<div><p><strong>第三方支付：</strong></p></div>
			 		<div class="sub-bank bankers">
			 			<label><input type="radio" name="bankCode" value="alipay"><span><img width="100" height="30" src="/images/bank/third01.gif" alt="支付宝"></span></label>
			 		</div>
      	</c-rt:when>
      	<c-rt:otherwise>
					<div><p><strong>银行支付：</strong></p></div>
	      	<div class="sub-bank bankers">
				 		<c-rt:forEach items="${bankCodeMenu.options}" var="bcm" varStatus="m">
				 			<label><input type="radio" name="bankCode" value="${bcm.key}"><span><img width="100" height="30" src="/images/bank/${bcm.key}.gif" alt="${bcm.value.name}"/></span></label>
				 		</c-rt:forEach>
				 	</div>
				 	<div><p><strong>第三方支付：</strong></p></div>
				 	<div class="sub-bank bankers">
					 	<label><input type="radio" name="bankCode" value="alipay"><span><img width="100" height="30" src="/images/bank/third01.gif" alt="支付宝"></span></label>
					 	<label><input type="radio" name="bankCode" value="quickmoney"><span><img width="100" height="30" src="/images/bank/third02.gif" alt="快钱"></span></label>
					 	<label><input type="radio" name="bankCode" value="tenpay"><span><img width="100" height="30" src="/images/bank/third03.gif" alt="财富通"></span></label>
					 	<label><input type="radio" name="bankCode" value="chinapay"><span><img width="100" height="30" src="/images/bank/third04.gif" alt="银联电子支付"></span></label>
		      </div>      	
      	</c-rt:otherwise>
      </c-rt:choose>
      <div><input type="radio" name="paytype" value="70"><strong>信用卡单期支付</strong></div>
      <div><p>支持以下银行信用卡单期直付，无需开通网银：</p></div>
      <div><span class="sub-bank"><img alt="信用卡单期直付银行" src="/images/payment_card_single.gif"></span></div>
      </li>
      <li class="w-pay payment-submit">
      	<input type="text" value="" id="ccode" name="ccode" maxlength="6" autocomplete="off">
      	<img id="iv" name="iv"><a href="#chImg" title="换张图" id="chang_image">换张图</a><br>
      	<span id="codeTip" class="msg rn" style="display:none">请填验证码</span>
      	<br>
      	<input type="hidden" id="editprovince" name="province" value=""/>
        <input type="hidden" id="editcity" name="city" value=""/>
        <input type="hidden" id="editdistrict" name="district" value=""/>
        <input type="hidden" id="editzipCode" name="zipCode" value=""/>
        <input type="hidden" id="editaddr" name="addr" value=""/>
        <input type="hidden" id="editcontactName" name="contactName" value=""/>
        <input type="hidden" id="editareaCode" name="areaCode" value=""/>
        <input type="hidden" id="editphone" name="phone" value=""/>
        <input type="hidden" id="editextension" name="extension" value=""/>
        <input type="hidden" id="editmobile" name="mobile" value=""/>
		  	<input type="hidden" id="editmail" name="mail" value="">
        <input type="hidden" id="editTotalAmount" name="editTotalAmount" value=""/>
        <input type="hidden" id="subVrtlBlnc2" value="0.0" />
        <input type="hidden" id="subGiftCard2" value="0.0" />
        <input type="hidden" id="tempTotalAmount" value=""/>
        <input type="hidden" id="finalTotalAmount" name="finalTotalAmount" value=""/>
        <input type="hidden" name="ismobileVaild" id="ismobileVaild" value="${ismobileVaild}"/>
      	<a href="javascript:void(0);" id="submitTuangou" class="btn-mid">提交订单</a>
      </li>
  </ul>
  </div><!-- 付款方式 -->
</div>
 </form>
 <div id="myAddBookDialog"></div>
 <div id="loadingData" style="display:none;">
	<img src="/images/loading.gif"/>资料处理中,请稍候...
 </div>
 <div id="mobileVaildDialog"></div>  
 <div id="dialog"></div>
</c-rt:if>